package idv.takeshi.software.productline.bookstore.domain.model.useraccount;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * A model class which represents as a Organization user account.
 * @author takeshi
 *
 */
@Entity
@Table(name = "ORGANIZATION_ACCOUNT")
public class OrganizationAccount extends UserAccount {
	
	@Column(name = "ORGANIZATION_NAME", nullable = false, length = 50)
	private String name;

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/* (non-Javadoc)
	 * @see idv.takeshi.software.productline.bookstore.model.useraccount.UserAccount#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj == null) { return false; }
		   if (obj == this) { return true; }
		   if (obj.getClass() != getClass()) {
		     return false;
		   }
		   OrganizationAccount rhs = (OrganizationAccount) obj;
		   return new EqualsBuilder()
		   	   .appendSuper(super.equals(rhs))
			   .append(this.name, rhs.name)
		       .isEquals();
	}

	/* (non-Javadoc)
	 * @see idv.takeshi.software.productline.bookstore.model.useraccount.UserAccount#hashCode()
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(19, 23).
		   appendSuper(super.hashCode()).
	       append(this.name).
	       toHashCode();
	}
	 
}
 
